package com.hs.srm.api.modules.purchasechange;

import com.alibaba.fastjson.JSON;
import com.hs.srm.admin.modules.orders.service.ScmPoItemService;
import com.hs.srm.admin.modules.purchasechange.entity.PurchaseChangeRecordEntity;
import com.hs.srm.admin.modules.purchasechange.service.PurchaseChangeRecordService;
import com.hs.srm.admin.modules.requisition.service.ProPurchRequestItemService;
import com.hs.srm.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author ych
 * @date 2020-04-20
 */
@Controller
@RequestMapping("/api/purchaseChange")
public class PurchaseChangeApi {

    @Autowired
    private PurchaseChangeRecordService purchaseChangeRecordService;

    @Autowired
    private ProPurchRequestItemService proPurchRequestItemService;

    @Autowired
    private ScmPoItemService scmPoItemService;

    /**
     * 采购变更申请
     */
    @ResponseBody
    @Transactional(rollbackFor = Exception.class)
    @RequestMapping(value = "/result", method = RequestMethod.POST)
    public R shenheResult(String jsonData) {
        PurchaseChangeRecordEntity purchaseChange = JSON.parseObject(jsonData, PurchaseChangeRecordEntity.class);
        boolean b = purchaseChangeRecordService.insert(purchaseChange);
        return R.ok();
    }

}
